$(document).ready(function(){
    let $dormlist = $('#dormlist')
    $.ajax({
        type: 'GET',
        url: 'http://dorm.zhangqx.com:8003/api/dormlist',
        headers: {
            'Authorization': localStorage.getItem('token')
        },
        success: function(response) {
            alert(response.message);
            console.log(response);
            if(response.status != 1){
                window.location.assign('/login')
            }
            else {
                let dormlist = response.dormlist;
                for(let i = 0; i < dormlist.length; i++){
                    let list = document.createElement('li');
                    list.innerHTML = JSON.stringify(dormlist[i]);
                    $dormlist.append(list)
                }
            }
        },
        error: function() {
            alert('error query');
        }
        });
});